From c92d32e1adc7ee2fcf014a9abf35039b59478bf3 Mon Sep 17 00:00:00 2001
From: Andreas Baierl <ichgeh@imkreisrum.de>
Date: Tue, 26 May 2015 09:23:00 -0400
Subject: [PATCH 3/9] arm:sunxi:disp: Fix csc calculations.

---
 drivers/video/sunxi/disp/de_fe.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/video/sunxi/disp/de_fe.c b/drivers/video/sunxi/disp/de_fe.c
index 92799a0..54dfe7f 100644
--- a/drivers/video/sunxi/disp/de_fe.c
+++ b/drivers/video/sunxi/disp/de_fe.c
@@ -1382,10 +1382,10 @@ __s32 DE_SCAL_Set_CSC_Coef_Enhance(__u8 sel, __u8 in_csc_mode,
 	__u32 i;
 	__s32 sinv, cosv; /* sin_tab: 7 bit fractional */
 
-	bright = bright * 64 / 100;
-	bright = saturation * 64 / 100;
-	bright = contrast * 64 / 100;
-	bright = hue * 64 / 100;
+	bright = DIV_ROUND_CLOSEST((clamp(bright, 0, 100) * 63), 100);
+	saturation = DIV_ROUND_CLOSEST((clamp(saturation, 0, 100) * 63), 100);
+	contrast = DIV_ROUND_CLOSEST((clamp(contrast, 0, 100) * 63), 100);
+	hue = DIV_ROUND_CLOSEST((clamp(hue, 0, 100) * 63), 100);
 
 	sinv = image_enhance_tab[8 * 12 + (hue & 0x3f)];
 	cosv = image_enhance_tab[8 * 12 + 8 * 8 + (hue & 0x3f)];
-- 
2.7.0

